<template>
	<view class="user">
		<view class="head_portrait">
			<view class="portrait">
				<image :src="userInfo.avatar || this.$imgUrl + configInfo.logo"></image>
				<view>
					<view>
						<span @click="getUserInfo">{{userInfo.nick||'授权登录'}}</span>
						<p>
							<image @click="skip('/pages/user/list/invite/invite')" src="../../static/user/36.png"></image>
							<image @click="skip('/pages/user/list/install/install?mobile='+userInfo.mobile)"
								src="../../static/user/15.png"></image>
						</p>
					</view>
					<p @click="getUserInfo">{{userInfo.mobile||'立即开启上门之旅吧~~'}}</p>
				</view>
			</view>
			<view class="remaining">
				<view class="top_up">
					<p>账户余额(元)</p>
					<span @click="skip('/pages/user/list/top_up/top_up?money='+userInfo.money)">充值</span>
				</view>
				<view class="xian"></view>
				<view class="sum">
					<p @click="skip('/pages/user/list/record/record')">
						<span>￥</span>{{userInfo.money||'0.00'}}
					</p>
					<span @click="skip('/pages/user/list/withdrawal/withdrawal')">提现</span>
				</view>
			</view>
		</view>
		<view class="main">
			<view>
				<view @click="skip('/pages/user/list/collect/collect')">
					<p>
						<image src="../../static/user/37.png" mode="widthFix"></image>
						<span>我的收藏</span>
					</p>
					<u-icon name="arrow-right" color="#333" size="15"></u-icon>
				</view>
				<view @click="skip('/pages/user/list/discounts/discounts')">
					<p>
						<image src="../../static/user/38.png" mode="widthFix"></image>
						<span>我的优惠券</span>
					</p>
					<u-icon name="arrow-right" color="#333" size="15"></u-icon>
				</view>
				<view @click="skip('/pages/user/list/group/group')">
					<p>
						<image src="../../static/user/43.png" mode="widthFix"></image>
						<span>我的团队</span>
					</p>
					<u-icon name="arrow-right" color="#333" size="15"></u-icon>
				</view>
				<view @click="skip('/pages/user/list/address/address')">
					<p>
						<image src="../../static/user/40.png" mode="widthFix"></image>
						<span>我的地址</span>
					</p>
					<u-icon name="arrow-right" color="#333" size="15"></u-icon>
				</view>
				<view @click="skip('/pages/user/list/takeOut/takeOut')">
					<p>
						<image src="../../static/user/80.png" mode="widthFix"></image>
						<span>提现绑定</span>
					</p>
					<u-icon name="arrow-right" color="#333" size="15"></u-icon>
				</view>
				<view @click="skip('/pages/user/list/recruitment/recruitment')">
					<p>
						<image src="../../static/user/41.png" mode="widthFix"></image>
						<span>技师招募</span>
					</p>
					<u-icon name="arrow-right" color="#333" size="15"></u-icon>
				</view>
				<view style="border: 0;" @click="skip('/pages/user/list/partner/partner')">
					<p>
						<image src="../../static/user/42.png" mode="widthFix"></image>
						<span>招募合伙人</span>
					</p>
					<u-icon name="arrow-right" color="#333" size="15"></u-icon>
				</view>
				<view @click="shows">
					<p style="display: flex;">
						<image src="../../static/user/111.png" mode="widthFix"></image>
						<span>联系客服</span>
					</p>
					<u-icon name="arrow-right" color="#333" size="15"></u-icon>
				</view>
				<!-- <view @click="skip('/pages/user/list/feedback/feedback')">
					<p>
						<image src="../../static/user/39.png"></image>
						<span>意见反馈</span>
					</p>
					<u-icon name="arrow-right" color="#333" size="15"></u-icon>
				</view> -->
			</view>
		</view>
		<!-- 联系客服 -->
		<u-popup :show="show" mode="center" @close="close">
			<view class="popup">
				<img :src="$imgUrl+popup.service_img">
				<p>客服电话：{{popup.service_tel}}<u-icon @click="copy(popup.service_tel)" name="file-text-fill" color="#333"
						size="18"></u-icon></p>
				<p>服务时间：{{popup.service_time}}</p>
				<p>服务微信：{{popup.service_wx}}<u-icon @click="copy(popup.service_wx)" name="file-text-fill" color="#333"
						size="18"></u-icon></p>
			</view>
		</u-popup>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				configInfo: {},
				show: false,
				popup: {}
			};
		},
		methods: {
			skip(url) {
				uni.navigateTo({
					url,
				})
			},
			getUserInfo() {
				this.$httpRequest('/user/getUserInfo').then(res => {
					this.userInfo = res.data;
				})
			},
			close() {
				this.show = false
			},
			shows() {
				this.$httpRequest('/index/getKeFu').then(res => {
					this.popup = res.data
					this.show = true
				})
			},
			copy(index) {
				this.$copyText(index).then(() => {
					uni.showToast({
						title: '复制成功',
						icon: 'none',
						duration: 2000
					});
				}, () => {
					uni.showToast({
						title: '复制失败',
						icon: 'none',
						duration: 2000
					});
				})
			},
			getConfigInfo() {
				this.$httpRequest('/index/index').then(res => {
					uni.setStorageSync('configInfo', JSON.stringify({
						logo: res.data.logo,
						site_title: res.data.site_title,
						withdraw_config: res.data.withdraw_config,
						app_id: res.data.wechat_app_id,
					}));
					this.getUserInfo()
				})
			},
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.getUserInfo()
			uni.stopPullDownRefresh();
		},
		onShow() {
			if (!uni.getStorageSync('configInfo')) {
				this.getConfigInfo()
			} else {
				this.getUserInfo()
			}
		}
	}
</script>

<style lang="less">
	.user {

		.popup {
			width: 600rpx;
			min-height: 300rpx;
			background-color: #fff;
			border-radius: 30rpx;

			&>img {
				width: 95%;
				height: 400rpx;
				display: block;
				margin: 20rpx auto;
				border-radius: 20rpx;
			}

			&>p {
				font-size: 14px;
				margin: 10rpx;
				display: flex;
			}
		}

		&>.main {
			width: 100%;
			padding: 60rpx 30rpx;
			box-sizing: border-box;
			background: url('../../static/user/411.png');
			background-size: 100% 100%;
			transform: translateY(-100rpx);

			&>view {
				width: 100%;
				background: #fff;
				padding: 0 34rpx;
				box-sizing: border-box;
				border-radius: 20rpx;

				&>view {
					width: 100%;
					height: 86rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					border-bottom: 1px solid #F0F0F0;

					&>p {
						font-size: 15px;

						&>image {
							width: 30rpx;
							margin-right: 20rpx;
							transform: translateY(4rpx);
							image-rendering: -moz-crisp-edges;
							image-rendering: -o-crisp-edges;
							image-rendering: -webkit-optimize-contrast;
							image-rendering: crisp-edges;
							-ms-interpolation-mode: nearest-neighbor;
						}
					}
				}
			}
		}

		&>.head_portrait {
			width: 100%;
			padding: 30rpx 30rpx;
			box-sizing: border-box;
			background: linear-gradient(180deg, #53C277 0%, #81E2A8 100%);
			color: #333;

			&>.remaining {
				width: 690rpx;
				height: 242rpx;
				margin: 34rpx auto 0;
				background: linear-gradient(138deg, #535353 0%, #292929 100%);
				border-radius: 20rpx;
				display: flex;
				flex-direction: column;
				align-items: center;

				&>.sum {
					width: 100%;
					padding: 10rpx 30rpx;
					box-sizing: border-box;
					position: relative;

					&>span {
						width: 100rpx;
						line-height: 46rpx;
						background: #646464;
						border-radius: 24rpx 0px 0px 24rpx;
						padding: 2rpx;
						text-align: center;
						color: #343434;
						position: absolute;
						right: 0;
						top: 50%;
						transform: translateY(-50%);
					}

					&>p {
						font-size: 18px;
						color: #fff;

						&>span {
							font-size: 12px;
						}
					}
				}

				&>.xian {
					width: 630rpx;
					height: 1px;
					background: #606060;
				}

				&>.top_up {
					width: 100%;
					height: 92rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;

					&>p {
						font-size: 12px;
						color: #999999;
						margin-left: 30rpx;
					}

					&>span {
						width: 100rpx;
						line-height: 46rpx;
						background: #646464;
						border-radius: 24rpx 0px 0px 24rpx;
						text-align: center;
						color: #343434;
					}
				}
			}

			&>.portrait {
				display: flex;

				&>image {
					width: 100rpx;
					height: 100rpx;
					border-radius: 50%;
					image-rendering: -moz-crisp-edges;
					image-rendering: -o-crisp-edges;
					image-rendering: -webkit-optimize-contrast;
					image-rendering: crisp-edges;
					-ms-interpolation-mode: nearest-neighbor;
				}

				&>view {
					margin-left: 30rpx;
					flex: 1;
					height: 100rpx;
					display: flex;
					flex-direction: column;
					justify-content: center;

					&>p {
						color: #5E5E5E;
						font-size: 12px;
					}

					&>view {
						display: flex;
						justify-content: space-between;
						font-size: 15px;

						&>p {
							display: flex;
							align-items: center;

							image {
								width: 38rpx;
								height: 38rpx;
								margin: 0 20rpx;
								image-rendering: -moz-crisp-edges;
								image-rendering: -o-crisp-edges;
								image-rendering: -webkit-optimize-contrast;
								image-rendering: crisp-edges;
								-ms-interpolation-mode: nearest-neighbor;
							}
						}
					}
				}
			}
		}
	}
</style>